You can identify and use the following tabs in RStudio: Source, Console, Environment, History, Files, Plots, Packages, Help and Viewer.
You can modify RStudio’s interface options to suit your needs.
Now that you have access to R & RStudio, let’s go on a quick tour of the RStudio interface, your digital home for the next few weeks.
First open RStudio either on the cloud or on your computer.
By default, RStudio is arranged into four window panes.
If you only see three panes, open a new script with
File > New File > R Script . This should reveal one
more pane.
Below we outline the four RStudio panes:
By default, the upper left pane is the source pane, where you view and edit source code from R Scripts and similar files.
The bottom left pane is usually the console pane, where you can type in commands and view output messages.
The top right pane has the Environment and History tabs, among others.
The bottom right pane has the Files, Plot and Help tabs, among others.
The source pane or editor is where your R ‘scripts’ go. A script is a text document where you write and save code.
Open a new script under the File menu if you have
not yet done so: File > New File > R Script. Here,
type the following:
print("excited for R!")To run code, place your cursor anywhere in the code,
then hit Command + Enter on macOS, or
Control + Enter on Windows.
This should send the code to the Console and run it.
You can also run multiple lines at once. To try this, type the following:
print("excited for R!")
print("and RStudio!")Now drag your cursor to highlight both lines and press
Command/Control + Enter.
There is also a ‘Run’ button at the top right of the source panel (
), with which you can
run code (either the current line, or all highlighted code). But you
should try to use the keyboard shortcut instead.
To run the entire script, use
Command/Control + A to select all
code, then press Command/Control +
Enter.
To open the script in a new window, click on the (
) icon in the toolbar
directly above the script.
To put the window back, click on the same button on the now external window.
Next, save the script. Hit
Command/Control + S to bring up
the Save dialog box. Save it with the name “rstudio_intro” in an
easy-to-locate part of your computer, perhaps your desktop.

You can view data frames (which are like spreadsheets in R) in the same source pane. To observe this, type and run the code below.
View(cars)Notice the uppercase V in View().
cars is the name of a dataset that comes loaded with R.
It shows the speed of cars and the distances taken to stop, as observed
in a study from the 1920s.
You can click on the “x” icon beside the tab name to close it.
The console, at the bottom left, is where code is executed. You can type code directly here, but it will not be saved.
Type a random piece of code (maybe a calculation) and press ‘Enter’.
If you place your cursor on the last line of the console, and you press the up arrow, you can go back to the last code that was run. Keep pressing it to cycle to the previous lines.
To run any of these previous lines, just press Enter.
The Environment tab shows datasets and other objects that are loaded into R’s working memory, or “workspace”.
To explore this tab, let’s import a dataset into your workspace from the web. Type the code below into your script and run it:
ebola_data <- read.csv("https://tinyurl.com/ebola-data-sample")You don’t need to understand exactly what the code is doing for now. We just want to quickly show you the basic features of the Environment pane; we’ll look at data importing in detail later.
Also, if you do not have active internet access, the code above will not run. You can skip this section and move to the “History” tab.
Now that the dataset is loaded, you can click on the blue drop-down icon beside the object’s name in the Environment tab to reveal a summary.

Clicking directly on the dataset opens it in a ‘View’ tab.
You can remove an object from the workspace with the
rm() function. Type and run the following in a new line on
your R script.
rm(ebola_data)The broom icon, at the top of the Environment pane can also be used to clear your workspace.
Try re-running the line
The History tab shows previous commands you have run.
You can use Shift-click to select multiple lines. Click the first item you want to select to highlight it, then scroll to the last item you want to select, hold down the “Shift” key and click that item.
Now you can send this to the Console or the Source using the icons at the top of the History pane.
The Tutorials tab gives you access to some interactive R tutorials. You can ignore it for now.
If you are on Rstudio.cloud, the Connections and Git tabs may also be visible. These can also be ignored for now.
Now, let’s take a look at the tabs in the bottom right pane.
First up, the Files tab. This shows the files and folders in the directory you are working in.
You can use this tab to look through our course repo.
Try playing with all the icons and buttons here, to see what they do.
Next, the Plots tab. This is where your plots show up. Try generating a simple plot with the following code:
plot(women)Play with the icons at the top of this tab to explore what they do. In particular, you should explore how to export a plot.
Next, the Packages tab shows what packages or libraries are installed on your device, and allows you to install and load new packages.

But it is better to install and load packages with R code, rather
than the Packages tab. Let’s try this. Type and run the
code below to install the {highcharter} package.
The first line installs the package. The second line loads the package.
install.packages("highcharter")
library(highcharter)Note that you only ever need to install a package once. But you need
to load it with library() each time you start a new R
session.
Fourth, the Help tab shows the documentation for different R objects. Try typing out and running each line below to see what this documentation looks like:
?print
?carsHelp files are not always very easy to understand for beginners, but with time they will become more useful.
Finally, the Viewer tab will allow you to preview
HTML files and interactive objects. Type and run the code below to make
an interactive histogram showing the speed of cars in the
cars dataset.
hchart(cars$speed)RStudio has a number of options for changing it’s look and functionality. Let’s try these now.
Open Tools > Global Options to bring up RStudio’s
options menu. Then:
Under Pane Layout, adjust the pane arrangement. The
arrangement we recommend is shown below.

Now, under Appearance, choose your ideal theme. (We
like the “Crimson Editor” and “Tomorrow Night” themes.)
Under Code > Display, check “Highlight R function
calls”. What this does is give your R functions a unique color,
improving readability.
Also under Code > Display, check “Rainbow
parentheses”. What this does is make your “nested parentheses” easier to
read by giving each pair a unique color.
Finally under General > Basic,
uncheck the box that says “Restore .RData into
workspace at startup”. You don’t want to restore any data to
your workspace (or environment) when you start RStudio.
Starting with a clean workspace each time is less likely to lead to
errors.
This also means that you never want to “save your workspace to .RData on exit”, so set this to Never.
Congratulations! You are now a new citizen of RStudio.
Of course, you have only scratched the surface of RStudio functionality. As you advance in your R journey, you will discover new features, and you will hopefully grow to love the wonderful integrated development environment (IDE) that is RStudio. One good place to start is the official RStudio IDE cheatsheet.
Below is one section of that sheet:
See you in the next lesson!
The following team members contributed to this lesson:
Some material in this lesson was adapted from the following sources: